﻿using Microsoft.Reporting.WebForms;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace CNKI.TPI.Web.UI.ReportInfo
{
    public partial class ShowReport : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            if (!IsPostBack && Session["reportdata"] != null)
            {

                string rptPath = "";
                string rptName = "";
                if (!string.IsNullOrEmpty(this.Request.QueryString["RPTPath"]))
                {
                    rptPath = this.Request.QueryString["RPTPath"].ToString();
                }
                ReportViewer1.LocalReport.ReportPath = Server.MapPath(rptPath);
                ReportDataSource reportDataSource = new ReportDataSource("DataSet1", Session["reportdata"]); //数据源

                if (!string.IsNullOrEmpty(this.Request.QueryString["RPTName"]))
                {
                    rptName = this.Request.QueryString["RPTName"].ToString();
                    if (rptName == "UserStatisticData" && !string.IsNullOrEmpty(this.Request.QueryString["SearchType"])) //用户资源统计
                    {
                        ReportParameter rp = new ReportParameter("SearchType", this.Request.QueryString["SearchType"].ToString());//参数
                        ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { rp });
                    }
                }

                reportDataSource.Name = rptName;  //数据源名称
                ReportViewer1.LocalReport.DataSources.Add(reportDataSource);
                ReportViewer1.LocalReport.Refresh();
            }
          
        }
    }
}